/*
 * @Author: 陈俊升 761723995@qq.com
 * @Date: 2023-08-23 14:59:00
 * @LastEditors: 陈俊升 761723995@qq.com
 * @LastEditTime: 2024-01-31 17:08:39
 * @FilePath: /hr_new_vue3/src/apis/human/base/dimissionSetting/index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { ajaxService } from '@/utils/request';
import * as Type from './type';

const env = import.meta.env;
// const baseURL = 'http://192.168.31.129:39003';

// const baseURL = env.VITE_DEV_BASE_URL;
const baseURL = env.VITE_DEV_BASE_URL;
/**
 * 离职类型及原因设置新增
 * @param data
 * @returns
 */
export function PostDimission(data: Type.dimissionType) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason/per/leave/reason',
    method: 'post',
    baseURL,
    data
  });
}
export function PutDimission(data: Type.dimissionType) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason/per/leave/reason',
    method: 'put',
    baseURL,
    data
  });
}

/**
 * 查询离职类型
 * @param params
 * @returns
 */
export function GetLeaveType() {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason',
    method: 'get',
    baseURL
  });
}

/**
 * 新增离职类型
 * @param params
 * @returns
 */
export function PostLeaveType(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason',
    method: 'post',
    baseURL,
    data
  });
}

/**
 * 修改离职类型
 * @param params
 * @returns
 */
export function PutLeaveType(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason',
    method: 'put',
    baseURL,
    data
  });
}

/**
 * 删除离职类型
 * @param params
 * @returns
 */
export function DelLeaveType(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason',
    method: 'delete',
    baseURL,
    params
  });
}

/**
 * 查询离职原因
 * @param params
 * @returns
 */
export function GetSession(params: Type.Page & { leaveType: number }) {
  return ajaxService<Type.SessionType>({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason/per/leave/reason/list',
    method: 'get',
    baseURL,
    params
  });
}
/**
 * 离职原因设置查重
 * @param params
 * @returns
 */
export function RepeatSession(params: { type: string; session: string }) {
  return ajaxService<Type.SessionType>({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason/check/repeat',
    method: 'get',
    baseURL,
    params
  });
}

/**
 * 查询离职类型
 * @param data
 * @returns
 */
export function GetType() {
  return ajaxService<Type.dimissionType[]>({
    url: '/pl/leave/offboarding/type',
    method: 'get',
    baseURL
  });
}

/**
 * 离职原因删除
 * @param data
 * @returns
 */
export function DelSession(data: { ids: number[] }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason/per/leave/reason',
    method: 'delete',
    baseURL,
    data
  });
}

/**
 * 离职原因启用
 * @param data
 * @returns
 */
export function EditSession(data: Type.dimissionType) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/leave_setting/leave_reason/per/leave/reason',
    method: 'put',
    baseURL,
    data
  });
}
